<?php

/**
 * singleton.php - Create a singleton instance of any class
 *
 * This allows me to use the singleton pattern when and where I need without
 * forcing a particular class to always be treated as a singleton.
 *
 * Note: This class depends on PHP5
 *
 * @author Toby Miller <tobius.miller@gmail.com>
 * @copyright 2008 Toby Miller <tobius.miller@gmail.com>
 * @license http://opensource.org/licenses/mit-license.php MIT License
 */

class Singleton
{
	private static $instances = array();

	public function get_instance($class)
	{
		if (!array_key_exists($class, self::$instances)) self::$instances[$class] = new $class;
		return self::$instances[$class];
	}
}

?>
